package route

import (
	"gitee.com/DonHz/cloud-file-storage/service/apigw/handler"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.LoadHTMLFiles("./static/view/index.html",
		"./static/view/signup.html",
		"./static/view/signin.html",
		"./static/view/home.html",
		"./static/view/download.html",
		"./static/view/upload.html",
	)
	r.Static("/static", "./static")

	r.GET("/user/signup", func(ctx *gin.Context) {
		ctx.HTML(http.StatusOK, "signup.html", gin.H{"msg": "ok"})
	})
	r.POST("/user/signup", handler.SignUpHandler)

	r.GET("/user/signin", func(ctx *gin.Context) {
		ctx.HTML(http.StatusOK, "signin.html", gin.H{"msg": "ok"})
	})
	r.POST("/user/signin", handler.SignInHandler)
	r.GET("/user/home", func(ctx *gin.Context) {
		ctx.HTML(http.StatusOK, "home.html", gin.H{"msg": "ok"})
	})
	r.POST("/user/info", handler.UserInfoHandler)

	return r
}
